﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.woodsoft.core;
using com.woodsoft.core.Files;
using EQ1.Objects;

namespace EQ1.Elements {
  public class StaticScreenPiece:ScreenPiece,IUIElement<StaticScreenPiece> {
    public StaticScreenPiece ( UIDocument doc , string name ) : base( doc , name ) {
      this.AutoDraw = true;
    }
    public StaticScreenPiece ( UIDocument doc ) : this( doc , "StaticScreenPiece" ) {
    }

    #region IUIElement<StaticScreenPiece> Members

    public void Validate ( StaticScreenPiece val , string name ) {
      UIClass par = ( UIClass ) this.ParentNode;

      if( val.LocalName != name ) {
        StaticScreenPiece el = new StaticScreenPiece( ( UIDocument ) val.OwnerDocument , name );
        el.Copy( val );
        val = el;
      }

      if( par.GetElement( name ) != null )
        par.RemoveElement( name );

      par.AppendChild( val );
    }
    public void Copy ( StaticScreenPiece val ) {
      base.Copy( val );

      this.AutoDraw = val.AutoDraw;
    }

    #endregion

    public bool AutoDraw {
      get {
        return bool.Parse(this.GetElement( "AutoDraw" ).InnerText);
      }
      set {
        this.Validate( "AutoDraw" , value.ToString() );
      }
    }
  }
}
